import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBJsonToModel/YBMineModel/YBMessageModel.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBNetWorkModule/YBBaseMineNetWork/YBBaseMineNetWork.dart';

class YBMineMessageProvider with ChangeNotifier{

  List<YBMessageModel> _mineMessageModel = List<YBMessageModel>();

  List<YBMessageModel> get mineMessageModelList => _mineMessageModel;

  RefreshController _easyRefreshController = RefreshController();

  RefreshController get easyRefresh => _easyRefreshController;



  void refreshData(){

    getMessageInfoData();
  }

  void getMessageInfoData(){
    YBMineNetWork.mineMessageInfoData({
      "sysCode":"xg_youbang",
    },success: (data){
       _mineMessageModel.clear();
      _easyRefreshController.refreshCompleted();
      List resultList = data;
      if (!ObjectUtil.isEmptyList(resultList)) {
        _mineMessageModel.addAll(resultList.map((e){
          return YBMessageModel.fromJson(e);
        }).toList());
        print('--2222222222-$_mineMessageModel--');
        notifyListeners();
      }

    },fail: (error){
      print('--error---$error');
    });
  }

}